/**
 * Author: 冯亮亮
 * Remark: 销售计划
 */
lyfdefine(['echarts', 'time-line', 'common/scm-plan-common-choosegoods'], function (echarts, time, scmPlanCommonChoosegoods) {
    return ({
            data: function () {
                return {
                    chooseGoodsDialog: false,
                    tableData: [],
                    dataList: [],
                    dialogVisible: false,
                    dialogFormVisible: false,
                    value10: true,
                    value1: '',
                    tableShow: true,
                    pickerOptions: {
                        shortcuts: [{
                            text: '最近一周',
                            onClick(picker) {
                                const nowDate = new Date();
                                const oneWeekDate = new Date(nowDate - 7 * 24 * 3600 * 1000);
                                let nowDayOfWeek = oneWeekDate.getDay(); // 本周的第几天
                                let nowDay = oneWeekDate.getDate(); // 当前日
                                let nowMonth = oneWeekDate.getMonth(); // 当前月
                                let nowYear = oneWeekDate.getFullYear(); // 当前年
                                let start = new Date(nowYear, nowMonth, nowDay - (nowDayOfWeek === 0 ? 7 : nowDayOfWeek) + 1)
                                let end = new Date(nowYear, nowMonth, nowDay - (nowDayOfWeek === 0 ? 7 : nowDayOfWeek) + 7)
                                picker.$emit('pick', [start, end]);
                            }
                        }, {
                            text: '最近一个月',
                            onClick(picker) {
                                let start = new Date();
                                start.setMonth(start.getMonth() - 1);
                                start.setDate(1);
                                const end = new Date();
                                let oneDay = 3600 * 1000 * 24
                                end.setDate(1)
                                end.setTime(end.getTime() - oneDay)
                                picker.$emit('pick', [start, end]);
                            }
                        }, {
                            text: '最近三个月',
                            onClick(picker) {
                                let start = new Date();
                                start.setMonth(start.getMonth() - 3);
                                start.setDate(1);
                                const end = new Date();
                                let oneDay = 3600 * 1000 * 24
                                end.setDate(1)
                                end.setTime(end.getTime() - oneDay)
                                picker.$emit('pick', [start, end]);
                            }
                        }]
                    },
                    charts: false,
                    cType: false,
                    checked: false,
                    a: '',
                    dialogVisible1: false,
                    dateList: [],
                    tables: [],
                    festivals: [],
                    echartsLoading: false,
                    weekDate: [],
                    needMergeArr: ['skuName'], // 有合并项的列
                    rowMergeArrs: {},
                    pageIndex: 1,
                    pageSize: 10,
                    totalPage: 0,
                    totalCount: 0,
                    dataForm: {
                        startTime: this.dateFormat('yyyy-MM-dd HH:mm:ss', new Date()),
                        quota1: [],
                        quota11: [],
                        layeredCodeList: [],
                        channelCodeList: [],
                        layeredCodes:[],
                        planTypeList: [],
                        unitType: 2
                    },
                    exportForm: {
                        pageNum: '',
                        pageSize: '',
                    },
                    dataListLoading: false,
                    warehouseOptions: [],
                    supplierOptions: [],
                    skuOptions: [],
                    targetOption: [
                        {
                            label: '销售计划量',
                            value: 1
                        },
                        {
                            label: '上次销售计划量',
                            value: 2
                        },
                        {
                            label: '销售确认量',
                            value: 3
                        },
                         {
                            label: '上次确认量',
                            value: 4
                        },
                        {
                            label: '计划与确认差值',
                            value: 5
                        },
                        {
                            label: '计划与确认差异比例',
                            value: 6
                        },
                        {
                            label: '预测计划量',
                            value: 7
                        },
                        {
                            label: '实际销量',
                            value: 8
                        }
/*                        {
                            label: '区总确认目标量',
                            value: 11
                        }, {
                            label: '片总确认目标量',
                            value: 12
                        }, {
                            label: '地总确认目标量',
                            value: 13
                        },*/
                    ],
                    currentPage4: '',
                    value2: ['销售计划量', '预测计划量', '计划与确认差异比例'],
                    labels: [],
                    props: {
                        checkStrictly: true,
                        multiple: true,
                        label: 'name',
                        value: 'code',
                        lazy: true,
                        lazyLoad: this.lazyLoad
                    },
                    props2: {
                        checkStrictly: true,
                        multiple: true,
                        label: 'name',
                        value: 'code',
                        lazy: true,
                        lazyLoad: this.lazyLoad2
                    },
/*                    props3: {
                        checkStrictly: true,
                        multiple: true,
                        label: 'name',
                        value: 'code',
                        lazy: true,
                        lazyLoad: this.lazyLoad3
                    },*/
                    unitOption: [],
                    serArr: [],
                    labels: [],
                    channelList: [],
                    pplanTargetDTOS: [],
                    planTypeList: [],
                    defaultUnit: '',
                    defaultUnitItem: {
                        name: '销售单位',
                        type: 2
                    }
                }
            },
            components: {
                scmPlanCommonChoosegoods
            },
            mounted() {
                let _this = this
                let beginOflastWeek = _this.getBeginOflastWeek()
                _this.dataForm.startTime = beginOflastWeek
                _this.dataForm.unitType = _this.defaultUnitItem.type
                this.getDataList()
                this.getUnit()
                _this.getChannelList()
                this.getPlanTypeList()
                _this.$http({
                    url: 'scm-plan-admin/api/v1/outService/dateLabels',
                    method: 'get',
                    params: {
                        "startDate": beginOflastWeek
                    }
                }).then(result => {
                    _this.festivals = result.data.data
                    _this.$nextTick(function () {
                        _this.initEcharts();
                        _this.initFestivals();
                    });
                })
            },
            methods: {
                getUnit() {
                    this.$http({
                        url: "scm-plan-admin/api/v1/outService/listUnitType",
                        method: 'GET'
                    }).then(result => {
                        const data = result.data;
                        if (data && data.code === '0') {
                            data.data.forEach(e => {
                                let obj = {}
                                obj.unitType = e.unitType
                                obj.unitName = e.unitName
                                this.unitOption.push(obj);
                            })

                        }
                    })
                },
                // 查询渠道下拉列表
                getChannelList() {
                    this.$http({
                        url: 'scm-plan-admin/api/v1/outService/queryByLevel?level=1',
                        method: 'GET'
                    }).then(result => {
                        this.channelList = result.data.data;
                    })
                },
                // 查询计划类型下拉列表
                getPlanTypeList() {
                    this.$http({
                        url: 'scm-plan-admin/api/v1/requirements/planTypes',
                        method: 'GET'
                    }).then(result => {
                        this.planTypeList = result.data.data;
                    })
                },
/*                lazyLoad3(node, resolve) {
                    if (node.level === 0) {
                        this.$http({
                            url: 'scm-plan-admin/api/v1/outService/queryByLevel?level=1',
                            method: 'GET'
                        }).then(result => {
                            const nodes = result.data.data;
                            resolve(nodes);
                        })
                    } else {
                        let parentCode = node.value
                        this.$http({
                            url: 'scm-plan-admin/api/v1/outService/parentChannel?parentChannel=' + parentCode,
                            method: 'GET'
                        }).then(result => {
                            const nodes = result.data.data;
                            if (nodes) {
                                nodes.forEach(e => e.level = 2)
                            }
                            resolve(nodes);
                        })

                    }
                },*/

                lazyLoad2(node, resolve) {
                    if (node.level === 0) {
                        this.$http({
                            url: 'scm-plan-admin/api/v1/outService/searchAreaByLevels',
                            method: 'POST',
                            data: [1]
                        }).then(result => {
                            const nodes = result.data.data.list;
                            resolve(nodes);
                        })
                    } else {
                        let parentCode = node.value
                        let storeParamDTO = {};
                        storeParamDTO.districtCode = parentCode;
                        //下拉选项框只显示到区域的级别，不显示到办事处  区域的level默认是3
                        if (3 === node.data.level) {
                            this.$http({
                                url: 'scm-plan-admin/api/v1/outService/listStore?pageNum=1&pageSize=9999',
                                method: 'POST',
                                data: JSON.stringify(storeParamDTO)
                            }).then(result => {
                                resolve(result.data.data)
                            })
                        } else {
                            this.$http({
                                url: 'scm-plan-admin/api/v1/outService/searchByParentCode?parentCode=' + parentCode,
                                method: 'GET'
                            }).then(result => {
                                const nodes = result.data.data;
                                resolve(nodes);
                            })
                        }
                    }
                },
                lazyLoad(node, resolve) {
                    if (node.level === 0) {
                        this.$http({
                            url: 'scm-plan-admin/api/v1/outService/getCategoryListByLevel?level=2',
                            method: 'POST'
                        }).then(result => {
                            const nodes = result.data.data;
                            resolve(nodes);
                        })
                    } else {
                        let stringList = [];
                        stringList.push(node.value);
                        this.$http({
                            url: 'scm-plan-admin/api/v1/outService/categoryListByCategoryCodes',
                            method: 'POST',
                            data: stringList
                        }).then(result => {
                            node.check = true;
                            const nodes = (result.data.data)[0].categoryDTOList;
                            const id = (result.data.data)[0].id;
                            if (nodes.length > 0) {
                                resolve(nodes);
                            } else {
                                this.$http({
                                    url: "scm-plan-admin/api/v1/outService/skuListByCategoryId/" + id + "/1/9999",
                                    method: 'GET'
                                }).then(result => {
                                    const node = result.data.data;
                                    resolve(node)
                                })
                            }
                        })
                    }

                },
                getDataListIndex() {
                    this.pageIndex++
                    this.getDataList()
                },
                debounce(fn, wait) {
                    var timer = null;
                    return function () {
                        if (timer !== null) {
                            clearTimeout(timer);
                        }
                        timer = setTimeout(fn, wait);
                    }
                },
                // 关闭窗口
                closeChooseGoodsDialog() {
                    this.chooseGoodsDialog = false
                },
                //查看日志
                choiceAllocationDetail() {
                    this.chooseGoodsDialog = true
                    this.$nextTick(() => {
                        this.$refs.scmPlanCommonChoosegoods.getDataList(3)
                    })
                },
                formatPeriod(datePeriod) {
                    let dateArray = datePeriod.split('-');
                    if (dateArray.length === 2) {
                        let startDate = dateArray[0].substr(5)
                        let endDate = dateArray[1].substr(5)
                        return `${startDate}-${endDate}`;
                    } else {
                        return dateArray[0].substr(5)
                    }
                },
                getDataList() {
                    let _this = this
                    this.tableShow = false
                    this.dataListLoading = true;
                    this.dataForm.pageSize = this.pageSize;
                    this.dataForm.pageNum = this.pageIndex;
                    this.$http({
                        url: "/scm-plan-admin/api/v1/demandPlan/listByWeek",
                        method: 'POST',
                        data: this.dataForm
                    }).then(result => {
                        const data = result.data;
                        if (data && data.code === '0') {
                            const result = data.data
                            if (result && result.dateList) {
                                this.weekDate = result.dateList;
                            }
                            let list;
                            if (result && result.infoList) {
                                list = result.infoList;
                            }
                            if (!list) {
                                this.dataList = [];
                                this.totalCount = 0;
                            } else {
                                this.handerDataList(list);
                                this.rowMergeArrs = this.rowMergeHandle(this.needMergeArr, this.dataList); // 处理合并数据
                                this.pageIndex = data.data.pageNum
                                if (data.data.hasNextPage) {
                                    let tmpTotalCount = (data.data.pageNum + 1) * this.pageSize
                                    if(this.totalCount < tmpTotalCount){
                                        this.totalCount = tmpTotalCount
                                    }
                                }
                                //计算十四周日期
                                this.initWeekDates(this.dataForm.startTime)
                            }
                        } else {
                            this.$message.error(result.data.msg);
                            this.dataList = [];
                            this.totalPage = 0;
                        }
                        this.dataListLoading = false;
                        this.$nextTick(e => {
                            _this.tableShow = true
                        })
                    }).catch(() => {
                        this.dataListLoading = false;
                    })
                },
                rowMergeHandle(arr, data) {
                    if (!Array.isArray(arr) && !arr.length) return false;
                    if (!Array.isArray(data) && !data.length) return false;
                    let needMerge = {};
                    arr.forEach(i => {
                        needMerge[i] = {
                            rowArr: [],
                            rowMergeNum: 0
                        };
                        data.forEach((item, index) => {
                            if (index === 0) {
                                needMerge[i].rowArr.push(1);
                                needMerge[i].rowMergeNum = 0;
                            } else {
                                if (item[i] === data[index - 1][i]) {
                                    needMerge[i].rowArr[needMerge[i].rowMergeNum] += 1;
                                    needMerge[i].rowArr.push(0);
                                } else {
                                    needMerge[i].rowArr.push(1);
                                    needMerge[i].rowMergeNum = index;
                                }
                            }
                        });
                    });
                    return needMerge;
                },
                mergeAction(val, rowIndex, colData) {
                    let _row = this.rowMergeArrs[val].rowArr[rowIndex];
                    let _col = _row > 0 ? 1 : 0;
                    return [_row, _col];
                },
                arraySpanMethod({row, column, rowIndex, columnIndex}) {
                    // 没办法循环判断具体是那一列 所以就只好写了多个if
                    // if (column.property === 'channel') return this.mergeAction('skuName', rowIndex, column);
                    // if (column.property === 'area') return this.mergeAction('skuName', rowIndex, column);
                    // if (columnIndex === 0) return this.mergeAction('skuName', rowIndex, column);
                    if (columnIndex === 0 || column.property == 'channel' || column.property == 'area' || column.property == 'skuName' || column.property == 'category' || column.property == 'unit' || column.property == 'planTypeName') {
                        if (this.isContain(this.dataForm.quota1, 0) && rowIndex % this.targetOption.length === 0) {
                            return {
                                rowspan: this.targetOption.length,
                                colspan: 1
                            }
                        } else if (this.isContain(this.dataForm.quota1, 0) && rowIndex % this.targetOption.length !== 0) {
                            return {
                                rowspan: 0,
                                colspan: 0
                            }
                        }
                        if (!this.isContain(this.dataForm.quota1, 0) && rowIndex % this.dataForm.quota1.length === 0) {
                            return {
                                rowspan: this.dataForm.quota1.length,
                                colspan: 1
                            }
                        } else if (!this.isContain(this.dataForm.quota1, 0) && rowIndex % this.dataForm.quota1.length !== 0) {
                            return {
                                rowspan: 0,
                                colspan: 0
                            }
                        }
                    }
                },
                isContain(list, item) {
                    if (list.length === 0) {
                        return true
                    }
                    let e = list.find(e => {
                        return e === item
                    })
                    if (e !== undefined) {
                        return true
                    } else {
                        return false
                    }
                },
                handerDataList(dataList) {
                    let newDataList = [];
                    let _this = this
                    dataList.forEach((item, index, array) => {
                        let confirmQty = []
                        let planProportionss = []
                        item.planProportionQty.forEach(item => {
                            let it = item != 0 ? (item * 100).toFixed(3) + "%" : "-"
                            planProportionss.push(it)
                        })
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 1)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                subChannelCode: item.subChannelCode,
                                planTypeName: item.planTypeName,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.salesPlanQtyLabel, // 供应商确认量（标识）
                                qtyList: item.salesPlanQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 2)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                subChannelCode: item.subChannelCode,
                                planTypeName: item.planTypeName,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.lastSalesPlanQtyLabel, // 上次销售计划量指标名称
                                qtyList: item.lastSalesPlanQty,               // 上次销售计划量
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 3)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                subChannelCode: item.subChannelCode,
                                planTypeName: item.planTypeName,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.confirmQtyLabel, // 销售确认量指标名称
                                qtyList: item.confirmQty,            // 销售确认量
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 4)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                subChannelCode: item.subChannelCode,
                                planTypeName: item.planTypeName,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.lastConfirmQtyLabel, // 供应商确认量（标识）
                                qtyList: item.lastConfirmQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 5)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                subChannelCode: item.subChannelCode,
                                planTypeName: item.planTypeName,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.planDifferenceLabel, // 计划与确认差值指标名称
                                qtyList: item.planDifferenceQty,            // 计划与确认差值
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 6)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                subChannelCode: item.subChannelCode,
                                planTypeName: item.planTypeName,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.planProportionLabel, // 计划与确认差异比例指标名称
                                qtyList: planProportionss,            // 计划与确认差异比例
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 7)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                subChannelCode: item.subChannelCode,
                                planTypeName: item.planTypeName,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.forecastPlanQtyLabel, // 供应商确认量（标识）
                                qtyList: item.forecastPlanQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 8)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                subChannelCode: item.subChannelCode,
                                planTypeName: item.planTypeName,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.actualSalesQtyLabel, // 实际销量指标名称
                                qtyList: item.actualSalesQty,               // 实际销量
                                flag: index,
                            });
                        }
/*                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 11)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                subChannelCode: item.subChannelCode,
                                planTypeName: item.planTypeName,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.confirmTarget2Label, // 区总确认目标指标名称
                                qtyList: item.confirmTarget2Qty,            // 区总确认目标量
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 12)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                subChannelCode: item.subChannelCode,
                                planTypeName: item.planTypeName,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.confirmTarget3Label, // 片总确认目标指标名称
                                qtyList: item.confirmTarget3Qty,            // 片总确认目标量
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 13)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                subChannelCode: item.subChannelCode,
                                planTypeName: item.planTypeName,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.confirmTarget4Label, // 地总确认目标指标名称
                                qtyList: item.confirmTarget4Qty,            // 地总确认目标量
                                flag: index,
                            });
                        }*/
                    });
                    this.dataList = newDataList
                },
                initFestivals() {
                    this.$refs.timeLine.vueComponent.festivalList = this.festivals
                    this.$refs.timeLine.vueComponent.initDate()
                },
                showDialog() {
                    this.dialogVisible = true
                    this.$nextTick(function () {
                        this.initEcharts();
                    });
                },
                initEcharts(boo) {
                    this.echartsLoading = true;
                    //基于准备好的dom，初始化echarts实例
                    let _this = this
                    let obj;
                    if (boo) {
                        this.dataForm.startTime = boo[0],
                            this.dataForm.endTime = boo[1]
                    }
                    this.$http({
                        url: "/scm-plan-admin/api/v1/demandPlan/listAll",
                        method: "POST",
                        data: this.dataForm
                    }).then(result => {
                        const data = result.data;
                        if (result.data.code === '0') {
                            _this.labels = []
                            this.serArr = []
                            _this.pplanTargetDTOS = []
                            if (result.data.data) {
                                result.data.data.labelData.forEach(e => {
                                    let str = {};
                                    str.key = e.key;
                                    str.label = e.label;
                                    _this.labels.push(e.label);
                                    _this.pplanTargetDTOS.push(str)
                                })
                                _this.dateList = result.data.data.dateList
                                if (_this.pplanTargetDTOS) {
                                    _this.pplanTargetDTOS.forEach(str => {
                                        let obj = {};
                                        let key1 = str.key;
                                        obj.data = result.data.data.value[key1];
                                        if ("predict_confirm_l4_scale" == key1) {
                                            obj.data = this.acFormat(obj.data)
                                            obj.type = "line";
                                            obj.yAxisIndex = "1";
                                        } else {
                                            obj.type = "bar";
                                        }
                                        obj.name = str.label;
                                        this.serArr.push(obj)
                                    })
                                }
                            }
                        } else {
                            this.echartsLoading = false;
                            _this.$message.error(result.data.msg);
                        }
                    }).then(e => {
                        _this.initOpentionEcharts()
                    })

                },
                acFormat(val) {
                    let acFormatQty = []
                    val.forEach(e => {
                        let qty = e
                        let qtys
                        if (qty === 0) {
                            qtys = (qty * 1000).toFixed(3)
                        } else {
                            qtys = (qty * 100).toFixed(3)
                        }
                        acFormatQty.push(qtys)
                    })
                    return acFormatQty
                },
                initOpentionEcharts() {
                    let _this = this
                    let ec = null;
                    if (echarts != undefined) {
                        ec = echarts;
                    } else {
                        ec = window.echarts;
                    }
                    var myChart = ec.init(document.getElementById('echarts'));
                    let arr = {}
                    let arr2 = []
                    this.serArr.forEach(e => {
                        let obj = _this.value2.find(e1 => {
                            return e1 === e.name
                        })
                        if (obj) {
                            arr2.push(e)
                        }
                    })
                    let option = {
                        color: ['#4BA2FD', '#5AD8A6', '#6DC8EC', '#945FB9'],
                        title: {
                            text: ''
                        },
                        dataZoom: [
                            {
                                type: 'slider',//有单独的滑动条，用户在滑动条上进行缩放或漫游。inside是直接可以是在内部拖动显示
                                show: true,//是否显示 组件。如果设置为 false，不会显示，但是数据过滤的功能还存在。
                                start: 0,//数据窗口范围的起始百分比0-100
                                end: 100,//数据窗口范围的结束百分比0-100
                                bottom: -10 //距离底部的距离
                            },
                            //2.在内部可以横向拖动
                            {
                                type: 'inside',// 内置于坐标系中
                                start: 0,
                                end: 100
                            }
                        ],
                        tooltip: {
                            trigger: 'axis',
                            axisPointer: {
                                type: 'cross',
                                crossStyle: {
                                    color: '#999'
                                }
                            }
                        },
                        dataZoom: [
                            {
                                show: true,
                                realtime: true,
                                start: 0,
                                end: 50
                            },
                            {
                                type: 'inside',
                                realtime: true,
                                start: 0,
                                end: 50
                            }
                        ],
                        legend: {
                            type: 'scroll',
                            orient: 'horizontal',
                            data: _this.value2,
                            selected: arr
                        },
                        grid: {
                            left: '3%',
                            right: '4%',
                            bottom: '3%',
                            containLabel: true
                        },
                        xAxis: {
                            type: 'category',
                            data: _this.dateList,
                            axisPointer: {
                                type: 'shadow'
                            }
                        },
                        yAxis: [
                            {
                                type: 'value',
                                name: '量',
                                axisLabel: {
                                    formatter: '{value}'
                                }
                            },
                            {
                                type: 'value',
                                name: '百分比',
                                axisLabel: {
                                    formatter: '{value} %'
                                },
                                splitLine: {     //去掉网格线
                                    show: false
                                }
                            }
                        ],
                        series: arr2
                    };
                    this.echartsLoading = false;
                    myChart.setOption(option, true);
                },
                offsetFun(val) {
                    let offSetNum = val.target.vueComponent.offSetNum
                    let obj = {
                        startTime: '',
                        endTime: ''
                    }
                    if (offSetNum === 16) {
                        obj.startTime = this.dateFormat('yyyy-MM-dd HH:mm:ss', val.target.vueComponent.dateList[val.target.vueComponent.offSetNum - 1].date),
                            obj.endTime = this.dateFormat('yyyy-MM-dd HH:mm:ss', val.target.vueComponent.dateList[val.target.vueComponent.offSetNum].date1)
                    } else {
                        obj.startTime = this.dateFormat('yyyy-MM-dd HH:mm:ss', val.target.vueComponent.dateList[val.target.vueComponent.offSetNum - 1].date)
                        obj.endTime = this.dateFormat('yyyy-MM-dd HH:mm:ss', val.target.vueComponent.dateList[val.target.vueComponent.offSetNum + 1].date)
                    }
                    this.dataForm.startTime = obj.startTime;
                    this.dataList = [];
                    this.pageIndex = 1;
                    this.totalCount = 0;
                    this.getDataList();
                },
                changePicker(val) {
                    this.initEcharts(val)
                },
                searchList() {
                    let _this = this;
                    this.dataList = [];
                    this.pageIndex = 1;
                    this.totalCount = 0;
                    this.dataForm.quota1 = this.dataForm.quota11;
                    this.dataForm.categoryCodeList = [];
                    this.$refs.tree.getCheckedNodes().forEach(e => {
                        _this.dataForm.categoryCodeList.push({
                            level: e.data.level,
                            code: e.data.code
                        })
                    });
                    let skuCodeS = _this.dataForm.skuCodeS;
                    if (skuCodeS && skuCodeS.length) {
                        let skuCode = skuCodeS.split(/[(\r\n)\r\n]+/);
                        skuCode.forEach(e => {
                            _this.dataForm.categoryCodeList.push({
                                level: 5,
                                code: e
                            })
                        })
                    }
/*                    this.dataForm.channelCodeList = []
                    this.$refs.tree3.getCheckedNodes().forEach(e => {
                        _this.dataForm.channelCodeList.push(e.data.code)
                    })*/
                    this.dataForm.areaCodeList = []
                    this.$refs.tree2.getCheckedNodes().forEach(e => {
                        _this.dataForm.areaCodeList.push({
                            level: e.data.level,
                            code: e.data.code
                        })
                    })
                    this.dataForm.layeredCodeList = []
                    if (this.dataForm.layeredCodes) {
                        this.dataForm.layeredCodes.forEach(e => {
                            this.dataForm.layeredCodeList.push(e)

                        })
                    }
                    this.getDataList()
                    this.initEcharts()
                    this.dialogVisible = false
                    this.dialogFormVisible = false
                },
                advancedSearch() {
                    this.dialogVisible = true
                },
                initData() {
                    this.tableData = []
                    this.tables = this.rowData[0]['dates']
                    for (let i = 0; i < 10; i++) {
                        this.rowData.push(this.rowData[0])
                    }
                    this.rowData.forEach(e => {
                        let channelCode = e['channelCode']
                        let gmvTarget = e.gmvTargets
                        gmvTarget.channelCode = channelCode
                        this.tableData.push(gmvTarget)
                        let gmvRealTarget = e.gmvRealTargets
                        gmvRealTarget.channelCode = channelCode
                        this.tableData.push(gmvTarget)
                        let a = e.a
                        a.channelCode = channelCode
                        this.tableData.push(a)
                        let b = e.b
                        b.channelCode = channelCode
                        this.tableData.push(b)
                    })
                },
                clearCondition() {
                    this.dataForm.skuCodeS = '';
                    this.dataForm.channelCodes = [];
                    this.dataForm.planTypeList = [];
                    this.dataForm.area = [];
                    this.dataForm.skuNodes = [];
                    this.dataForm.quota11 = [];
                    this.dataForm.layeredCodes = [];
                },
                sizeChangeHandle(val) {
                    this.pageSize = val;
                    this.pageIndex = 1;
                    this.totalCount = 0;
                    this.getDataList();
                },
                currentChangeHandle(val) {
                    this.pageIndex = val;
                    this.getDataList();
                },
                fullScreen() {
                    let _this = this
                    _this.dialogVisible1 = true
                    if (_this.$refs.table.selection && _this.$refs.table.selection.length) {
                        let selection = _this.$refs.table.selection
                        let rows = []
                        selection.forEach(item => {
                            rows.push(item)
                        })
                        //赋值全屏table
                        _this.$nextTick(function () {
                            this.$refs.tablemax.clearSelection();
                            if (rows) {
                                rows.forEach(row => {
                                    _this.$refs.tablemax.toggleRowSelection(row, true);
                                });
                            }
                        });
                    }
                },
                leaveFullScreen() {
                    let _this = this
                    _this.dialogVisible1 = false
                    if (_this.$refs.tablemax.selection && _this.$refs.tablemax.selection.length) {
                        let selection = _this.$refs.tablemax.selection
                        let rows = []
                        selection.forEach(item => {
                            rows.push(item)
                        })
                        //赋值全屏table
                        this.$refs.table.clearSelection();
                        if (rows) {
                            rows.forEach(row => {
                                _this.$refs.table.toggleRowSelection(row, true);
                            });
                        }
                    }
                },

                open(msg) {
                    this.$alert(msg, '提示', { confirmButtonText: '确定' });
                },
                command(val) {
                    let _this = this;
                    //下标集合
                    _this.exportForm.rowIndex = [];
                    //渠道集合
                    _this.exportForm.channelCodeList = _this.dataForm.channelCodeList;
                    //计划类型
                    _this.exportForm.typeList = _this.dataForm.planTypeList;
                    //仓库
                    // _this.exportForm.warehouseCodeList = _this.dataForm.warehouseCodeList;
                    //区域
                    _this.exportForm.areaCodeList = _this.dataForm.areaCodeList;
                    //品类
                    _this.exportForm.categoryCodeList = _this.dataForm.categoryCodeList;
                    //起始时间
                    _this.exportForm.startTime = _this.dataForm.startTime;
                    //分页信息
                    _this.exportForm.pageSize = _this.pageSize;
                    _this.exportForm.pageNum = _this.pageIndex;
                    //是否编辑
                    _this.exportForm.edit = _this.dataForm.edit;
                    //TODO 单位
                    _this.exportForm.unitType = _this.dataForm.unitType;
                    //TODO 分层
                    _this.exportForm.layeredCodeList = _this.dataForm.layeredCodes;
                    let boo = false
                    if (val === 2) {
                        let array = []
                        if (this.dialogVisible1) {
                            if (this.$refs.tablemax.selection && this.$refs.tablemax.selection.length > 0) {
                                this.$refs.tablemax.selection.forEach(e => {
                                    array.push(e.flag)
                                })
                            } else {
                                boo = true
                            }
                        } else {
                            if (this.$refs.table.selection && this.$refs.table.selection.length > 0) {
                                this.$refs.table.selection.forEach(e => {
                                    array.push(e.flag)
                                })
                            } else {
                                boo = true
                            }
                        }
                        this.exportForm.rowIndex = [...new Set(array)]
                    }

                    if (boo) {
                        this.$message({
                            message: '请选择至少一条数据',
                            type: 'error'
                        })
                        return false
                    }
                    const loading = this.$loading({
                        lock: true,
                        text: '下载中···   ',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)'
                    });
                    this.$http({
                        url: '/scm-plan-admin/api/v1/demandPlan/exportExcel',
                        method: 'post',
                        // responseType: 'blob',
                        data: this.exportForm,
                        params: {type: val}
                    }).then(result => {
                        loading.close();
                        this.open(result.data.data);
                        /*let data = result.data;
                        let fileReader = new FileReader();
                        fileReader.onload = function () {
                            try {
                                let jsonData = JSON.parse(this.result);  // 说明是普通对象数据，后台转换失败
                                loading.close();
                                if (jsonData.msg) {
                                    _this.$message({
                                        message: jsonData.msg,
                                        type: 'error'
                                    })
                                }
                            } catch (err) {   // 解析成对象失败，说明是正常的文件流
                                const disposition = result.headers['content-disposition'];
                                let fileName = disposition.substring(disposition.indexOf('filename=') + 9, disposition.length);
                                fileName = decodeURIComponent(fileName);
                                let blob = new Blob([data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
                                if ('download' in document.createElement('a')) { // 非IE下载
                                    const elink = document.createElement('a');
                                    elink.download = fileName;
                                    elink.style.display = 'none';
                                    elink.href = URL.createObjectURL(blob);
                                    document.body.appendChild(elink);
                                    elink.click();
                                    URL.revokeObjectURL(elink.href); // 释放URL 对象
                                    document.body.removeChild(elink)
                                } else { // IE10+下载
                                    navigator.msSaveBlob(blob, fileName);
                                }
                                loading.close();
                            }
                        };
                        fileReader.readAsText(data, "utf-8");*/
                    }).catch(function (e) {
                        loading.close();
                    })
                },
                download(data) {
                    if (!data) {
                        return
                    }
                    let url = window.URL.createObjectURL(new Blob([data]))
                    let link = document.createElement('a')
                    link.style.display = 'none'
                    link.href = url
                    link.setAttribute('download', 'excel.xlsx')

                    document.body.appendChild(link)
                    link.click()
                }, labelChange(val) {
                    this.initOpentionEcharts()
                }, dateFormat(fmt, date) {

                    let ret;
                    const opt = {
                        "y+": date.getFullYear().toString(),        // 年
                        "M+": (date.getMonth() + 1).toString(),     // 月
                        "d+": date.getDate().toString(),            // 日
                        "H+": date.getHours().toString(),           // 时
                        "m+": date.getMinutes().toString(),         // 分
                        "s+": date.getSeconds().toString()          // 秒
                        // 有其他格式化字符需求可以继续添加，必须转化成字符串
                    };
                    for (let k in opt) {
                        ret = new RegExp("(" + k + ")").exec(fmt);
                        if (ret) {
                            fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
                        }
                        ;
                    }
                    ;
                    return fmt;
                }, findStyle({row, column, rowIndex, columnIndex}) {
                    if (column.label && typeof parseInt(column.label.substr(0, 1)) === 'number' && !isNaN(column.label.substr(0, 1))) {
                        return "padding: 0;background: #4ba2fd;color: #ffffff"
                    } else {
                        return "padding: 0;background: #f8f8f8"
                    }
                },//获取上一周的开始时间
                getBeginOflastWeek() {
                    let nowdate = new Date();
                    let oneweekdate = new Date(nowdate - 7 * 24 * 3600 * 1000);
                    let nowDayOfWeek = oneweekdate.getDay(); // 本周的第几天
                    let nowDay = oneweekdate.getDate(); // 当前日
                    let nowMonth = oneweekdate.getMonth(); // 当前月
                    let nowYear = oneweekdate.getFullYear(); // 当前年
                    let weekStartDate = new Date(nowYear, nowMonth, nowDay - (nowDayOfWeek == 0 ? 7 : nowDayOfWeek) + 1)
                    let y = weekStartDate.getFullYear();
                    // let m = String(weekStartDate.getMonth() + 1).length === 1 ? '0' + (weekStartDate.getMonth() + 1) : weekStartDate.getMonth() + 1;
                    // let d = String(weekStartDate.getDate()).length === 1 ? '0' + weekStartDate.getDate() : weekStartDate.getDate();
                    let m = weekStartDate.getMonth() + 1;
                    let d = weekStartDate.getDate();
                    let formatwdate = y + '-' + m + '-' + d;
                    return formatwdate;
                },
                /*点击单位触发事件*/
                commandUnit(val) {
                    this.defaultUnit = val.unitName
                    this.dataForm.unitType = val.unitType;
                    this.getDataList();
                    this.initEcharts();
                },indexContent(val){
                    switch(val) {
                        case '销售计划金额':
                            return '单品-全渠道每周销售计划金额总和(零售白牌价)（单个商品在门店的白牌价、在渠道的白牌价）';
                            break;
                        case '预测计划金额':
                            return '单品-全渠道每周预测计划金额总和(零售白牌价)（单个商品在门店的白牌价、在渠道的白牌价）';
                            break;
                        case '销售计划量':
                            return '单品-全渠道每周销售计划数量总和';
                            break;
                        case '预测计划量':
                            return '单品-全渠道每周预测计划数量总和';
                            break;
                        case '安全库存量':
                            return '各RDC仓库安全库存量总和';
                            break;
                        case '上次确认量':
                            return '全渠道上次确认计划量总和';
                            break;
                        case '预约在途采购量':
                            return '已执行预约的采购单量总和';
                            break;
                        case '实际销量':
                            return '当前每周实际销售量';
                            break;
                        case '未履约采购量':
                            return '未执行预约的采购单量总和';
                            break;
                        case '当前实时库存':
                            return '当前各RDC实时库存总和';
                            break;
                        case '区总确认目标':
                            return '区总确认目标';
                            break;
                        case '片总确认目标':
                            return '片总确认目标';
                            break;
                        case '地总确认目标':
                            return '地总确认目标';
                            break;
                        case '上次销售计划量':
                            return '上次销售计划量';
                            break;
                        case '确认量':
                            return '确认量';
                            break;
                        case '计划与确认差值':
                            return '计划与确认差值';
                            break;
                        case '计划与确认差异比例':
                            return '计划与确认差异比例';
                            break;
                        default:
                            return ''
                    }
                }
            },
            template: `
    <div>
                <el-card class="box-card">
                <el-dialog  :visible.sync="chooseGoodsDialog" title="任务列表"  width="80%" :modal="true">
            <span>
            <scmPlanCommonChoosegoods v-if="chooseGoodsDialog" ref="scmPlanCommonChoosegoods"  @closeChooseGoodsDialog="closeChooseGoodsDialog"></plan-common-choosegoods>
          </span>
        </el-dialog>
              <div slot="header" class="clearfix">
                <div style="text-align: right;margin: 5px">
                <span style="float: left;color: rgba(0,0,0,0.85);font-size: 16px;line-height:35px">时间范围</span>
                <el-button  size="small"  style="float: left;margin-left: 10px"  @click="fullScreen" >全屏</el-button>
                 <el-button size="small"  icon="el-icon-search" type="primary" style="float: right;margin-left: 10px" @click="dialogFormVisible = true">高级搜索</el-button>
                 <el-dialog title="高级搜索" style="text-align: left" width="70%" :visible.sync="dialogFormVisible">
                    <div>   
                 <el-row>
                 <el-form :inline="true" label-width="100px" :model="dataForm"  size="small"  class="demo-form-inline">
                 <el-row>
                  <el-col :span="8">
                    <el-form-item label="渠道选择:">
                      <el-select v-model="dataForm.channelCodeList" multiple  placeholder="请选择">
                        <el-option
                          v-for="item in channelList"
                          :key="item.code"
                          :label="item.name"
                          :value="item.code">
                        </el-option>
                      </el-select>
                      </el-form-item>
                      </el-col>                                                                          <el-col :span="8">
                              <el-form-item label="计划类型选择:">
                              <el-select v-model="dataForm.planTypeList" multiple clearable filterable style="width: 100%">
                                  <el-option
                                  v-for="(key,value) in planTypeList"
                                  :key="value"
                                  :label="key"
                                  :value="value"
                                  ></el-option>
                              </el-select>
                            </el-form-item>
                            </el-col>
                      <el-col :span="8">
                      <el-form-item label="区域选择:">
                     <el-cascader
                    v-model="dataForm.area"
                    :props="props2" ref="tree2"
                    ></el-cascader>
                      </el-form-item>
                      </el-col>

</el-row> 
<el-row>
                      <el-col :span="8">
                      <el-form-item label="商品选择:">
                          <el-cascader :props="props" ref="tree" v-model="dataForm.skuNodes"></el-cascader>
                      </el-form-item>
                      </el-col>
                      
                <el-col :span="8">
                              <el-form-item label="商品编码:">
                              <el-input type="textarea"
                              :autosize="{ minRows: 1, maxRows: 4}" style="width:210px;" placeholder="请输入商品编码"
                              v-model="dataForm.skuCodeS"
                              clearable></el-input>
                            </el-form-item>
                            </el-col>
                            
</el-row>

<!--<el-row>
                    <el-col :span="24">
                              <el-form-item label="分层类型:" v-show="(dataForm.channelCodes && dataForm.channelCodes.length) || (dataForm.area && dataForm.area.length)">
                                    <el-select  style="width:100%" @change="dataForm.layeredCodes = []" v-model="dataForm.randType" clearable placeholder="请选择">
                                        <el-option label="销量分层" value="sale"></el-option>
                                        <el-option label="销售额分层" value="amount"></el-option>
                                    </el-select>
                                </el-form-item>
                                </el-col>
                              <el-col :span="24">
                              <el-form-item label="商品分层:" v-show="((dataForm.channelCodes && dataForm.channelCodes.length) || (dataForm.area && dataForm.area.length)) && dataForm.randType && dataForm.randType.length">
                                <el-checkbox-group v-model="dataForm.layeredCodes">
                                             <el-checkbox label="A">A</el-checkbox>
                                             <el-checkbox label="B">B</el-checkbox>
                                             <el-checkbox label="C">C</el-checkbox>
                                             <el-checkbox label="D">D</el-checkbox>
                              </el-checkbox-group>
                              </el-form-item>
                              </el-col></el-row>--><el-row>
                              <el-col :span="24">
                                  <el-form-item label="指标选择:">
                                        <el-checkbox-group v-model="dataForm.quota11">
                                        <el-row>
                                            <el-col :span="6"  v-for="item in targetOption">
                                             <el-checkbox :key="item.value" :label="item.value">{{ item.label }}</el-checkbox></el-col>
                                        </el-row>
                                        </el-checkbox-group>
                                  </el-form-item>
                              </el-col>
                              </el-row>
                            </el-form>
                        </el-row>
                        <div slot="footer" style="text-align: center">
                            <span class="dialog-footer">
                            <el-button size="mini" @click="clearCondition">清 除 条 件</el-button>
                            <el-button type="primary" size="mini" @click="searchList">搜 索</el-button>
                          </span>
                        </div>  
                    </div>
                  </el-dialog>
                  <el-button size="small" type="primary" style="margin-right: 5px"  @click="choiceAllocationDetail">任务列表</el-button>
                  <el-dropdown @command="commandUnit">
                      <el-button type="info"  size="small" style="margin-left: 5px;">
                        {{defaultUnit?defaultUnit:defaultUnitItem.name}}<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i></el-button>
                      <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item v-for="item in unitOption" :command="item">{{item.unitName}}</el-dropdown-item>                      
                      </el-dropdown-menu>
                  </el-dropdown>
                  
                  <el-dropdown @command="command">
                      <el-button type="primary"  size="small" >
                        导出<i class="el-icon-arrow-down el-icon--right"></i></el-button>
                      <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item :command="1">当前页数据</el-dropdown-item>
                        <el-dropdown-item :command="2">已勾选数据</el-dropdown-item>
                        <el-dropdown-item :command="3">所有查询结果</el-dropdown-item>
                      </el-dropdown-menu>
                    </el-dropdown>
                
             </div>
              </div>
            <time-line ref="timeLine" @offsetFun="offsetFun"></time-line>
            <el-table v-loading="dataListLoading" v-if="dataList.length === 0 "></el-table>
            <el-table
                :data="dataList"
                :span-method="arraySpanMethod"
                center
                ref="table"
                  v-show="dataList.length"
                border
                v-loading="dataListLoading"
                highlight-current-rows
                height="33vh"
                :header-row-style="{height: '20px',fontSize: '14px', fontWeight: '700',lineHeight: '36px',textAlign: 'center',backgroundColor: '#f3f4f4',padding: 0}"
                :row-style="{ color: '#999A9A', height: '16px',fontSize: '12px', fontWeight: 400,lineHeight: '26px',textAlign: 'center'}"
                :cell-style="{padding: 0}"
                  :header-cell-style="findStyle"
                style="width: 100%;padding: 0"
                :highlight-current-row="false">
            <el-table-column
                    type="selection"
                     fixed="left"
                    width="55">
            </el-table-column>
           <el-table-column
            width="130"
                  prop="channel"
                  fixed="left"
                  label="渠道" align="left">
                  <template slot-scope="scope">
                    {{scope.row.channel}}                  
                    </template>
                </el-table-column>
                <el-table-column width="80" prop="planTypeName" fixed="left" label="计划类型" align="left">
                  <template slot-scope="scope">
                      {{scope.row.planTypeName}}
                    </template>
                </el-table-column>
                <el-table-column
                width="130"
                  prop="area"
                  fixed="left"
                  label="区域" align="left">
                   <template slot-scope="scope">
                        {{scope.row.area}}
                    </template>
                </el-table-column>
                <el-table-column
                  prop="category"
                  width="130"
                  fixed="left"
                  label="品类" align="left">
                </el-table-column>
                <el-table-column
                  prop="skuName"
                  fixed="left"
                  width="130"
                  label="商品" align="left">
                  <template slot-scope="scope">
                  {{scope.row.skuName != null ? scope.row.skuName + "/" + scope.row.skuCode : scope.row.skuCode}}                   
                  </template>
                </el-table-column>
                <el-table-column
                width="130"
                fixed="left"
                  prop="planConfirmLabel" label="指标" align="left">
                   <template slot-scope="scope">
                         <el-tooltip class="item" effect="dark" :content="indexContent(scope.row.planConfirmLabel)" placement="top">
                          <span>{{ scope.row.planConfirmLabel }}</span>
                        </el-tooltip>
              </template>
                </el-table-column>
            <el-table-column
              v-for="(week, index) in weekDate" :label="week"
               width="120" align="right">
               <template slot-scope="scope">
                  <span>{{scope.row.qtyList[index] == 0? '-' : scope.row.qtyList[index] }}</span>
              </template>
        </el-table>
            <div style=";width: 100%;">
                <div style="height: 30px;width: 1px"></div>
                <el-row>
                 <span style="margin-left: 20px">日期范围</span>
                <el-date-picker
                  v-model="value1"
                  @change="changePicker"
                  type="daterange"
                  size="mini"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  align="right"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  :picker-options="pickerOptions">  
                </el-date-picker>
                <el-select v-model="value2" size="mini" clearable collapse-tags :multiple-limit="4" multiple placeholder="请选择指标" @change="labelChange">
                    <el-option
                      v-for="item in labels"
                      :key="item"
                      :label="item"
                      :value="item">
                    </el-option>
                  </el-select>
                 <el-pagination
                 background
                 @size-change="sizeChangeHandle"
                 @current-change="currentChangeHandle"
                 :current-page="pageIndex"
                 :page-sizes="[10, 20, 30, 50]"
                 :page-size="pageSize"
                 :total="totalCount"
                 :page-count="totalPage"
                  small
                  style="float: right"
                  layout="sizes, prev, pager, next">
                </el-pagination>
                </el-row>
                <div  v-loading="echartsLoading" style="margin-top: 20px;height: 30vh;width: 100%;" id="echarts"></div>
            </div>
            </el-card>
        <el-dialog
          center
          :style="{ padding: '0px' }"
          fullscreen
          :show-close="false"
          :visible.sync="dialogVisible1">
           <div style="">
           <div style="text-align: right;margin: 5px">
           <el-button  size="small" style="float: left;margin-left: 10px" @click="leaveFullScreen">退出全屏</el-button>
           <el-button size="small"  icon="el-icon-search" type="primary" style="float: right;margin-left: 10px" @click="dialogFormVisible = true">高级搜索</el-button>
                 <el-dialog title="高级搜索" append-to-body style="text-align: left" width="70%" :visible.sync="dialogFormVisible">
                    <div>   
                 <el-row>
                 <el-form :inline="true" label-width="100px" :model="dataForm"  size="small"  class="demo-form-inline">
                 <el-row>
                  <el-col :span="8">
                    <el-form-item label="渠道选择:">
                       <el-select v-model="dataForm.channelCodeList" multiple  placeholder="请选择">
                        <el-option
                          v-for="item in channelList"
                          :key="item.code"
                          :label="item.name"
                          :value="item.code">
                        </el-option>
                      </el-select>
                      </el-form-item>
                      </el-col>
                      <el-col :span="8">
                              <el-form-item label="计划类型选择:">
                              <el-select v-model="dataForm.planTypeList" multiple clearable filterable style="width: 100%">
                                  <el-option
                                  v-for="(key,value) in planTypeList"
                                  :key="value"
                                  :label="key"
                                  :value="value"
                                  ></el-option>
                              </el-select>
                            </el-form-item>
                            </el-col>
                      <el-col :span="8">
                      <el-form-item label="区域选择:">
                     <el-cascader
                    v-model="dataForm.area"
                    :props="props2" ref="tree2"
                    ></el-cascader>
                      </el-form-item>
                      </el-col>

</el-row> 
<el-row>
                      <el-col :span="8">
                      <el-form-item label="商品选择:">
                          <el-cascader :props="props" ref="tree" v-model="dataForm.skuNodes"></el-cascader>
                      </el-form-item>
                      </el-col>
                <el-col :span="8">
                              <el-form-item label="商品编码:">
                              <el-input type="textarea"
                              :autosize="{ minRows: 1, maxRows: 4}" style="width:210px;" placeholder="请输入商品编码"
                              v-model="dataForm.skuCodeS"
                              clearable></el-input>
                            </el-form-item>
                            </el-col>
</el-row>
<!--<el-row>
<el-col :span="24">
                              <el-form-item label="分层类型:" v-show="(dataForm.channelCodes && dataForm.channelCodes.length) || (dataForm.area && dataForm.area.length)">
                                    <el-select  style="width:100%" @change="dataForm.layeredCodes = []" v-model="dataForm.randType" clearable placeholder="请选择">
                                        <el-option label="销量分层" value="sale"></el-option>
                                        <el-option label="销售额分层" value="amount"></el-option>
                                    </el-select>
                                </el-form-item>
                                </el-col>
                              <el-col :span="24">
                              <el-form-item label="商品分层:" v-show="((dataForm.channelCodes && dataForm.channelCodes.length) || (dataForm.area && dataForm.area.length)) && dataForm.randType && dataForm.randType.length">
                                <el-checkbox-group v-model="dataForm.layeredCodes">
                                             <el-checkbox label="A">A</el-checkbox>
                                             <el-checkbox label="B">B</el-checkbox>
                                             <el-checkbox label="C">C</el-checkbox>
                                             <el-checkbox label="D">D</el-checkbox>
                              </el-checkbox-group>
                              </el-form-item>
                              </el-col></el-row>--><el-row>
                              <el-col :span="24">
                                  <el-form-item label="指标选择:">
                                        <el-checkbox-group v-model="dataForm.quota11">
                                        <el-row>
                                            <el-col :span="6"  v-for="item in targetOption">
                                             <el-checkbox :key="item.value" :label="item.value">{{ item.label }}</el-checkbox></el-col>
                                        </el-row>
                                        </el-checkbox-group>
                                  </el-form-item>
                              </el-col>
                              </el-row>
                            </el-form>
                        </el-row>
                        <div slot="footer" style="text-align: center">
                            <span class="dialog-footer">
                            <el-button size="mini" @click="clearCondition">清 除 条 件</el-button>
                            <el-button type="primary" size="mini" @click="searchList">搜 索</el-button>
                          </span>
                        </div>  
                    </div>
                  
</el-dialog>
<el-button size="small" type="primary" style="margin-right: 5px"  @click="choiceAllocationDetail">任务列表</el-button>
                      <el-dropdown @command="commandUnit">
                      <el-button type="info" size="small" style="margin-left: 5px;">
                         {{defaultUnit?defaultUnit:defaultUnitItem.name}}<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i></el-button>
                      <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item v-for="item in unitOption" :command="item">{{item.unitName}}</el-dropdown-item>                      
                      </el-dropdown-menu>
                    </el-dropdown>
                 <el-dropdown @command="command">
                      <el-button size="small" type="primary" >
                        导出<i class="el-icon-arrow-down el-icon--right"></i></el-button>
                      <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item :command="1">当前页数据</el-dropdown-item>
                        <el-dropdown-item :command="2">已勾选数据</el-dropdown-item>
                        <el-dropdown-item :command="3">所有查询结果</el-dropdown-item>
                      </el-dropdown-menu>
                    </el-dropdown>
                    </div>
                    <el-table v-loading="dataListLoading" v-if="dataList.length === 0 "></el-table>
                <el-table
                :data="dataList"
                :span-method="arraySpanMethod"
                center
                ref="tablemax"
                border
                v-show="dataList.length"
                v-loading="dataListLoading"
                highlight-current-rows
                height="85vh"
                :header-row-style="{height: '20px',fontSize: '14px', fontWeight: '700',lineHeight: '36px',textAlign: 'center',backgroundColor: '#f3f4f4',padding: 0}"
                :row-style="{ color: '#999A9A', height: '16px',fontSize: '12px', fontWeight: 400,lineHeight: '26px',textAlign: 'center'}"
                :cell-style="{padding: 0}"
                  :header-cell-style="findStyle"
                style="width: 100%;padding: 0"
                :highlight-current-row="false">
            <el-table-column
                    type="selection"
                     fixed="left"
                    width="55">
            </el-table-column>
           <el-table-column
            width="130"
                  prop="channel"
                  fixed="left"
                  label="渠道" align="left">
                  <template slot-scope="scope">
                      {{scope.row.channel}}
                    </template>
                </el-table-column>
                <el-table-column width="80" prop="planTypeName" fixed="left" label="计划类型" align="left">
                  <template slot-scope="scope">
                      {{scope.row.planTypeName}}
                    </template>
                </el-table-column>
                <el-table-column
                width="130"
                  prop="area"
                  fixed="left"
                  label="区域" align="left">
                   <template slot-scope="scope">
                        {{scope.row.area}}
                    </template>
                </el-table-column>
                <el-table-column
                  prop="category"
                  width="130"
                  fixed="left"
                  label="品类" align="left">
                </el-table-column>
                <el-table-column
                  prop="skuName"
                  fixed="left"
                  width="130"
                  label="商品" align="left">
                  <template slot-scope="scope">
                      {{scope.row.skuName != null ? scope.row.skuName + "/" + scope.row.skuCode : scope.row.skuCode}}
                  </template>
                </el-table-column>
                <el-table-column
                width="130"
                fixed="left"
                  prop="planConfirmLabel" label="指标" align="left">
                    <template slot-scope="scope">
                         <el-tooltip class="item" effect="dark" :content="indexContent(scope.row.planConfirmLabel)" placement="top">
                          <span>{{ scope.row.planConfirmLabel }}</span>
                        </el-tooltip>
              </template>
                </el-table-column>
            <el-table-column
                v-for="(week, index) in weekDate"
              :label="week" width="120" align="right">
              <template slot-scope="scope">
                  <span>{{scope.row.qtyList[index] == 0? '-' : scope.row.qtyList[index] }}</span>
              </template>
            </el-table-column>
        </el-table>
          <el-pagination
          background
                 @size-change="sizeChangeHandle"
                 @current-change="currentChangeHandle"
                 :current-page="pageIndex"
                 :page-sizes="[10, 20, 30, 50]"
                 :page-size="pageSize"
                 :total="totalCount"
                  small
                  style="float: right"
                  layout="sizes, prev, pager, next">
                </el-pagination>
           </div>
          <span slot="footer" class="dialog-footer">
          </span>
        </el-dialog>

    </div>
    `
        }
    );
});
